// pages/my/dispatchstatedestail/dispatchstatedestail.js
Page({
  data: {
    bottomHeight: getApp().globalData.bottomHeight,
    id: "",
    takenUserId: "",
    historyId: "",
    reviewStatus: "",
    detail: {},
    fileList: [],
    fileList2: [],
    fileList3: [],
    fileList4: [],
  },
  onLoad: function (options) {
    this.setData({
      id: options.id,
      takenUserId: options.takenUserId,
      historyId: options.historyId,
      reviewStatus: options.reviewStatus
    });
    this.getData();
  },
  getData() {
    getApp().globalData.http.reDetail({
      id: this.data.id,
      takenUserId: this.data.takenUserId
    }).then(res => {
      let tmp = res.data;
      tmp.imgUrls = tmp.imgUrls.split(",");
      this.setData({
        detail: res.data,
      });
      if (res.data.reviewStatus != 0) {
        this.setData({
          fileList: res.data.takenHistoryVo.firstEvidenceImgIds.length > 0 ? res.data.takenHistoryVo.firstEvidenceImgIds.split(",") : [],
          fileList2: res.data.takenHistoryVo.firstReviewImgIds.length > 0 ? res.data.takenHistoryVo.firstReviewImgIds.split(",") : [],
          fileList3: res.data.takenHistoryVo.secondEvidenceImgIds.length > 0 ? res.data.takenHistoryVo.secondEvidenceImgIds.split(",") : [],
          fileList4: res.data.takenHistoryVo.secondReviewImgIds.length > 0 ? res.data.takenHistoryVo.secondReviewImgIds.split(",") : [],
        });
      }
    });
  },
  pass(e) {
    getApp().globalData.http.evidence({
      id: this.data.id,
      historyIds: this.data.historyId,
      reviewStatus: 2
    }).then(res => {
      getApp().globalData.vant.toast({
        type: "success",
        message: "审核成功",
        duration: 1000,
        onClose: () => {
          wx.navigateBack();
        },
      });
    });
  },
  reject(e) {
    wx.navigateTo({
      url: `/pages/my/auditreject/auditreject?taskId=${this.data.id}&historyId=${this.data.historyId}&reviewStatus=${this.data.reviewStatus}`,
    });
  },
  previewImg(e) {
    let arr = e.currentTarget.dataset.img;
    let current = e.currentTarget.dataset.current;
    getApp().globalData.util.previewImage(arr, current);
  }
})